from django.conf.urls import url
from . import views
from django.contrib.auth.decorators import login_required

urlpatterns = [
    # 注册路由
    url(r'^register/$',views.UserRegiserView.as_view()),
    # 校验用户名路由
    url(r'^usernames/(?P<username>\w{5,20})/count/$',views.CheckUsernameView.as_view()),
    # 校验手机号路由
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$',views.CheckPhoneView.as_view()),
    #登陆路由
    url(r'^login/$',views.UserLoginView.as_view()),

    url(r'^logout/$',views.UserLogoutView.as_view()),
    url(r'^info/$',views.UserCenterInfoView.as_view()),
    # url(r'^info/$',login_required(views.UserCenterInfoView.as_view())),
    url(r'^emails/$',views.EmailView.as_view()),
    url(r'^emails/verification/$',views.EmailView.as_view()),
    url(r'^addresses/$',views.UserAddressView.as_view()),
    url(r'^addresses/create/$',views.UserAddressCreateView.as_view()),
    url(r'^addresses/(?P<address_id>\d+)/$',views.UserAddressUpdateView.as_view()),
    url(r'^addresses/(?P<address_id>\d+)/default/$',views.UserAddressDefaultView.as_view()),
    url(r'^addresses/(?P<address_id>\d+)/title/$',views.UserAddressTitleView.as_view()),
    url(r'^password/$',views.UserRepasswordView.as_view()),

    # 获取找回密码页面
    url(r'^find_password/$',views.FindPasswordView.as_view()),
    # 找回密码
    url(r'^accounts/(?P<username>\w{5,20})/sms/token/$',views.CheckUserView.as_view()),
    # 发送短信验证码
    url(r'^sms_codes/$',views.SendMsgView.as_view()),
    # 第二步表单提交，验证手机号，获取修改密码的access_token
    url(r'accounts/(?P<username>\d+)/password/token/$',views.FormCommitView.as_view()),
    #
    url(r'^users/(?P<user_id>\d+)/password/$',views.ChangePwdView.as_view()),
]